<?php

class MHoa extends CI_Model
{
	function danhsachhoa($madm)
	{
		$this->db->where('madm', $madm);
		$this->db->where('hienthi', 'true');		
		return $this->db->get('hoa')->result();
	}
	
	function thongtinhoa($mahoa)
	{
		$this->db->where('mahoa', $mahoa);
		return $this->db->get('hoa')->row();
	}
	
	function danhsachhoamoinhat()
	{
		$this->db->order_by('mahoa', 'desc');
		return $this->db->get('hoa', 12, 0)->result();
	}
	
	function DanhSachHoaDacBiet()
	{
		$this->db->order_by('gia', 'desc');
		return $this->db->get('hoa', 4, 0)->result();	
	}
	
	function xoahoa($mahoa)
	{
		$this->db->where('mahoa', $mahoa);
		$this->db->delete('hoa');
	}
	
	function themhoa($tenhoa, $gia, $soluong, $hinhanh, $mota, $hienthi, $madm)
	{
		$this->db->set('tenhoa', $tenhoa);
		$this->db->set('gia', $gia);
		$this->db->set('soluong', $soluong);
		$this->db->set('hinhanh', $hinhanh);
		$this->db->set('mota', $mota);
		$this->db->set('hienthi', $hienthi);
		$this->db->set('madm', $madm);
		$this->db->insert('hoa');
	}
	
	function capnhathoa($mahoa, $tenhoa, $gia, $soluong, $hinhanh, $mota, $hienthi)
	{
		$this->db->where('mahoa', $mahoa);
		$this->db->set('tenhoa', $tenhoa);
		$this->db->set('gia', $gia);
		$this->db->set('soluong', $soluong);
		$this->db->set('hinhanh', $hinhanh);
		$this->db->set('mota', $mota);
		$this->db->set('hienthi', $hienthi);
		$this->db->update('hoa');
	}
	
	function danhsachhoaAdmin()
	{
		return $this->db->get('hoa')->result();
	}
	
}

?>